﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Write.NET.Repositories
{
    /// <summary>
    /// This interface will be implemented by Repository classes
    /// </summary>
    /// <typeparam name="T">T should be the an entity class</typeparam>
    public interface IRepository<T>
    {
        /// <summary>
        /// Get all T objects
        /// </summary>
        /// <returns>Queryable T objects</returns>
        IQueryable<T> GetAll();
        /// <summary>
        /// Finds and returns a T object with matching id
        /// </summary>
        /// <param name="id">id to search for</param>
        /// <returns>T object with matching id</returns>
        T GetById(int id);
        /// <summary>
        /// Finds and returns a T object with matching name
        /// </summary>
        /// <param name="name">The string representation of the object to search for</param>
        /// <returns>T object with matching name</returns>
        T GetByName(string name);
        /// <summary>
        /// Insert new T object
        /// </summary>
        /// <param name="t">T object to be inserted</param>
        void Add(T t);
        /// <summary>
        /// Updates existing T object with new T object
        /// </summary>
        /// <param name="t">The new T object to replace an old T object</param>
        void Update(T t);
        /// <summary>
        /// Deletes a T object with matching id
        /// </summary>
        /// <param name="id">id to search and delete</param>
        void Delete(int id);
    }
}
